package com.test.demo.javabasis.mutithread;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

public class FutureDemo {
    public static void main(String[] args) {
        FutureTask futureTask = new FutureTask(()->{
            return "call";
        });
        futureTask.run();
        CompletableFuture<String> stringCompletableFuture = CompletableFuture.supplyAsync(() -> {
            return "call";
        });

        try {
            System.out.println(stringCompletableFuture.get());
            System.out.println(futureTask.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }


        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    throw new Exception("1");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).start();

    }
}
